Release 10.1A: OpenEdge Data Management:
DataServer for Microsoft SQL Server


Additional ProDataSet support

As demonstrated previously in Example 3–25, the LOAD-RESULT-INTO functionality provides a very fast and efficient way to populate the temp-table(s) of a ProDataSet Object.

Example 3–26, a two-part example, builds on the techniques demonstrated in Example 3–25, but shows the ProDataSet object BEFORE-FILL procedure can be modified to provide a single ProDataSet data access object that can be used against native OpenEdge or against MS SQL Server and other DataServer data sources.

DEFINE VARIABLE rid-1 AS ROWID. 
DEFINE VARIABLE rdi-2 AS ROWID. 
DEFINE TEMP-TABLE ttCust LIKE Sports.Customer 
       FIELD tRecid AS ROWID 
       FIELD tRECID_ident AS INT. 
DEFINE VAR hSendSQL AS HANDLE EXTENT 1. 
hSendSQL[1]=TEMP-TABLE ttCust:HANDLE. 
DEFINE DATASET dsCust FOR ttCust. 
DEFINE VAR phDataSet AS HANDLE NO-UNDO. 
DEFINE QUERY qCust FOR Customer. 
phDataSet=DATASET dsCust:HANDLE. 
phDataSet:SET-CALLBACK-PROCEDURE (“BEFORE-FILL”, “preDataSetFill”, 
THIS-PROCEDURE). 
DEFINE DATA-SOURCE dsCust FOR QUERY qCust. 
BUFFER ttCust:HANDLE:ATTACH:ATTACH-DATA-SOURCE(DATA-SOURCE 
     dsCust:HANDLE,?,?,?. 
DATASET dsCust:FILL(). 
FIND FIRST Customer WHERE Customer.custnum=1 NO-LOCK. 
rid-1=ROWID(customer). 
FIND FIRST Customer WHERE Customer.custnum=1 NO-LOCK. 
rid-2=ttCust.tRecid. 
IF rid-1 <> rid-2 THEN MESSAGE “The same record but different ROWID’s”. 
IF rid-1=rid-2 THEN MESSAGE “Congratulations - we have the same ROWID’s”. 
MESSAGE string(ttCust.Trecid) VIEW-AS ALERT-BOX. 
PROCEDURE preDataSetFill: 
DEFINE INPUT PARAMETER DATASET FOR dsCust. 
    DEFINE VAR handle1 AS INTEGER. 
    DEF VAR hSendSQL AS HANDLE EXTENT 1. 
hSendSQL[1]=TEMP-TABLE ttCust:HANDLE. 
IF DBTYPE(NUM-DBS)<>”PROGRESS” THEN DO: 
    DISPLAY “DataServer FILL using SEND-SQL”. 
    BUFFER ttCust:handle:FILL-MODE=”NO-FILL”. 
    RUN STORED-PROC send-sql-statement LOAD-RESULT-INTO hSendSQL 
             (“select * from customer”). 
   END. 
ELSE DO: /* normal OpenEddge FILL procedure */ 
   DISPLAY “Native Progress FILL”. 
   QUERY qCust:QUERY-PREPARE(“for each customer”).
END. 
END PROCEDURE. /* preDataSetFill */ 

Example 3–26: Use the LOAD-RESULT-INTO technique with BEFORE-FILL method to fill the temp-table(s) of a ProDataSet

Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095